package 草稿包;

import java.util.Arrays;
import java.util.Scanner;

/**
 * TODO
 *
 * @Description
 * @Author Lx
 * @Date 2024/5/18 18:48
 **/
public class solve1 {

    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();//组数
        while(n--!=0){
            int a=sc.nextInt();
            int b=sc.nextInt();

            int cnt=0;
            if(a%2==0)cnt++;
            if(b%2==0)cnt++;

            if(cnt%2==1) System.out.println("1");
            else System.out.println("0");

        }

    }
}
